#include <iostream>
#include <vector>

using namespace std;

int pickdp(int x, int y, int z, vector<vector<vector<int>>>& test) {
    if (x < 0 || x > 9 || y < 0 || y > 8 || z < 0 || z > 7) {
        return 0;
    }
    return test[x][y][z];
}




int process(int a, int b, int maxrest , vector<vector<vector<int>>>& test) 
{
    // Initialize base case
    test[a][b][0] = 1;

    // Perform dynamic programming
    for (int z = 1; z <= maxrest; z++) {
        for (int x = 0; x < 10; x++) {
            for (int y = 0; y < 9; y++) {
                test[x][y][z] = pickdp(x - 2, y + 1, z - 1, test);
                test[x][y][z] += pickdp(x - 1, y + 2, z - 1, test);
                test[x][y][z] += pickdp(x + 1, y + 2, z - 1, test);
                test[x][y][z] += pickdp(x + 2, y + 1, z - 1, test);
                test[x][y][z] += pickdp(x - 2, y - 1, z - 1, test);
                test[x][y][z] += pickdp(x - 1, y - 2, z - 1, test);
                test[x][y][z] += pickdp(x + 1, y - 2, z - 1, test);
                test[x][y][z] += pickdp(x + 2, y - 1, z - 1, test);
            }
        }
    }

    return test[0][0][maxrest];
}

int main() {
    int a = 7;
    int b = 7;
    int maxrest = 7;

    vector<vector<vector<int>>> dp(10  , vector<vector<int>>(9 , vector<int>(8 , 0)));
    int result = process(a, b, maxrest , dp);

    cout << "Number of ways: " << result << endl;

    return 0;
}

